package com.CampaignManager.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PlayerResource {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	public Key getId() {
		return this.id;
	}
	
	@Persistent
	private Player player;	
	public Player getPlayer() {
		return this.player;
	}
	public void setPlayer(Player p) {
		this.player = p;
	}
	
	@Persistent
	private String resource;
	public String getResource() {
		if (ownerEmail == null) ownerEmail = player.getEmail();
		return resource;		
	}
	public void setResource(String resource) {
		this.resource = resource;
	}
	
	@Persistent
	private Long amount;
	public Long getAmount() {
		if (amount == null ) amount = 0L;
		return amount;
	}
	public void setAmount(Long amount) {
		this.amount = amount;
	}
	
	@Persistent
	private String ownerEmail;
	public String getOwnerEmail() {
		if (ownerEmail == null) ownerEmail = player.getEmail();
		return ownerEmail;		
	}
	public void setOwnerEmail(String ownerEmail) {
		this.ownerEmail = ownerEmail;
	}
}
